var e = require("../../../api.js"), a = getApp();

Page({
    data: {
        feedback: "",
        order_no: ""
    },
    onLoad: function(e) {
        this.setData({
            order_no: e.order_no
        }), e.uid && a.shareCouponsMessage(e.uid);
    },
    bindTextAreaBlur: function(e) {
        console.log(e.detail.value), this.setData({
            feedback: e.detail.value
        });
    },
    orderFeedbackHandler: function() {
        var t = this;
        null === this.data.feedback || "" === this.data.feedback ? wx.showToast({
            title: "请输入订单意见",
            icon: "none"
        }) : wx.showModal({
            title: "订单反馈",
            content: "是否提交",
            success: function(o) {
                o.confirm && (wx.showLoading({}), a.request({
                    url: e.order_feedback.order_feedback,
                    method: "post",
                    data: {
                        order_no: t.data.order_no,
                        msg: t.data.feedback
                    },
                    success: function(e) {
                        wx.hideLoading(), 1 == e.code ? (wx.showToast({
                            title: "提交成功"
                        }), wx.navigateBack({
                            delta: 1
                        })) : (wx.showToast({
                            title: e.msg,
                            icon: "none"
                        }), wx.navigateBack({
                            delta: 1
                        }));
                    }
                }));
            },
            fail: function() {
                wx.showToast({
                    title: "提交失败",
                    icon: "none"
                });
            }
        });
    },
    onShareAppMessage: function() {
        return {
            title: a.shareAppMessage().title,
            imageUrl: a.shareAppMessage().imageUrl,
            desc: a.shareAppMessage().desc,
            path: a.shareAppMessage().path
        };
    }
});